//
//  NSDate+GL.m
//  GLLibDemo
//
//  Created by huanggulong on 2017/4/22.
//  Copyright © 2017年 历山大亚. All rights reserved.
//

#import "NSDate+GL.h"

@implementation NSDate (GL)

- (NSDate *)gl_firstTime{
    NSCalendar *cal = [NSCalendar currentCalendar];
    NSDateComponents *components = [cal components:(NSCalendarUnitEra|NSCalendarUnitYear|NSCalendarUnitMonth|NSCalendarUnitDay) fromDate:self];
    return [cal dateFromComponents:components];
}

- (NSDate *)gl_lastTime{
    NSCalendar *cal = [NSCalendar currentCalendar];
    NSDateComponents *components = [cal components:(NSCalendarUnitEra|NSCalendarUnitYear|NSCalendarUnitMonth|NSCalendarUnitDay) fromDate:self];
    [components setHour:24];//向前进24小时  进入第二天时间
    [components setSecond:-1];//再向后退1秒钟  进入前一个的那一刻
    return [cal dateFromComponents:components];
}

@end
